<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>从Session中获取值</h1>
<span th:text="${#session.getAttribute('data')}"></span><br>
<span th:text="${#httpSession.getAttribute('data')}"></span><br>
<span th:text="${session.data}"></span>

<script type="text/javascript" th:inline="javascript">
    //http://localhost:8080/springboot/user/detail
    //获取协议名称
    let scheme = [[${#request.getScheme()}]];
    console.log(scheme)
    //获取服务器名称
    let serverName = [[${#request.getServerName()}]];
    console.log(serverName)
    //获取服务器端口号
    let serverPort = [[${#request.getServerPort()}]];
    console.log(serverPort)
    let contextPath = [[${#request.getContextPath()}]];
    console.log(contextPath)
    let allPath = scheme+"://"+serverName+":"+serverPort+contextPath;
    // alert(allPath)
    let requestUrl = [[${#httpServletRequest.requestURL}]];
    let queryString = [[${#httpServletRequest.queryString}]];
    let requestAddress = requestUrl + "?" + queryString;
    alert(requestAddress)
</script>
</body>
</html>